package com.jackstraw.jack_base.datasource.database.parten.base.entity.page;

import com.jackstraw.jack_base.util.entity.BaseEntity;
import lombok.Data;

import java.util.List;

/**
 * 分页工具类
 */
@Data
public class PageData<T> extends BaseEntity<T> {

    /**
     * 总记录数
     */
    private Long total;

    /**
     * 每页记录数
     */
    private Integer pageSize;

    /**
     * 页码（从0开始）
     */
    private Integer pageNum;

    /**
     * 列表数据
     */
    private List<T> list;


    /**
     * 默认
     */
    public PageData() {
    }

    /**
     * 分页
     *
     * @param list  列表数据
     * @param total 总记录数
     */
    public PageData(List<T> list, Long total) {
        this.list = list;
        this.total = total;
    }

    public PageData(Integer pageSize, Integer pageNum) {
        this.pageSize = pageSize;
        this.pageNum = pageNum;
    }

    public PageData(Long total, Integer pageSize, Integer pageNum, List<T> list) {
        this.total = total;
        this.pageSize = pageSize;
        this.pageNum = pageNum;
        this.list = list;
    }

}